Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Foundation for the correction of BIP-32 incompatability issue. #176

Merged
merged 1 commit into from Nov 18, 2020
Merged

Fix: Foundation for the correction of BIP-32 incompatability issue. #176

merged 1 commit into from Nov 18, 2020

Conversation

johnsonjh
Copy link

@johnsonjh johnsonjh commented Nov 5, 2020

This is the first phase of the fix, which should not introduce any incompatibilities, but I'm still going to do some extensive regression testing of this one first before I'll be recommending that you merge it.

The Child code was is in use in the following places in the pktwallet source code, where it now uses the DeriveNonStandard method:

pktwallet/waddrmgr/manager.go:1259
pktwallet/waddrmgr/manager.go:1265
pktwallet/waddrmgr/manager.go:1287
pktwallet/waddrmgr/manager.go:1302
pktwallet/waddrmgr/manager.go:1307
pktwallet/waddrmgr/scoped_manager.go:286
pktwallet/waddrmgr/scoped_manager.go:835
pktwallet/waddrmgr/scoped_manager.go:852
pktwallet/waddrmgr/scoped_manager.go:1035

I'm also using the DeriveNonStandard at the following locations in the integration test code (which shouldn't be necessary) - but I'm just being highly conservative here:

integration/rpctest/memwallet.go:130
integration/rpctest/memwallet.go:342
integration/rpctest/memwallet.go:476

Again, I have NOT changed, in this PR, the wallet to actually use the corrected and compatible Derive method, to avoid introducing wallet backwards incompatibility:

"If you were previously using the Child method, know this method is incompatible. The Child method had a BIP-32 standards compatibility issue. You have to check whether any hardened derivations in your derivation path are affected by this issue, via the new IsAffectedByIssue172() method, and migrate the wallet if so. The new and corrected method (Derive) does conform to all the standards. If you need the old behavior, then use DeriveNonStandard()."

A future PR will update the code, use IsAffectedByIssue172(), and include wallet migration code, at which time the DeriveNonStandard method can be safely switched over at the above places in the sources to use properly standards-compliant Derive method.

* One in 128 accounts are not BIP-32 compatible

* See upstream: btcsuite/btcwallet#719

* Bug introduced at: btcsuite/btcutil#172 (!!!)

This is the first phase of the fix, which
should not introduce any incompatabilities,
but I'm still going to do some extensive
regression testing of this one first before
I'll be recommending that you merge it.

The .Child code was is in use in the following
places in the pktwallet source code, where it
now uses the DeriveNonStandard method:

pktwallet/waddrmgr/manager.go:1259
pktwallet/waddrmgr/manager.go:1265
pktwallet/waddrmgr/manager.go:1287
pktwallet/waddrmgr/manager.go:1302
pktwallet/waddrmgr/manager.go:1307
pktwallet/waddrmgr/scoped_manager.go:286
pktwallet/waddrmgr/scoped_manager.go:835
pktwallet/waddrmgr/scoped_manager.go:852
pktwallet/waddrmgr/scoped_manager.go:1035

I'm also using the DeriveNonStandard at
the following locations in the integration
test code (which shouldn't be necessary) -
I'm just being highly conservative here.

integration/rpctest/memwallet.go:130
integration/rpctest/memwallet.go:342
integration/rpctest/memwallet.go:476

Again, I have NOT changed in this PR the
wallet to actually use the corrected and
compatible Derive method, as it would a
introduce wallet backwards incompatability:

"If you were previously using the Child method,
know this method is incompatible. The Child
method had a BIP-32 standards compatibility
issue. You have to check whether any hardened
derivations in your derivation path are affected
by this issue, via the new IsAffectedByIssue172()
method, and migrate the wallet if so. The new and
corrected method (Derive) does conform to all the
standards. If you need the old behavior, then use
DeriveNonStandard()."

A future update will use IsAffectedByIssue172()
and include wallet migration code, at which time
the DeriveNonStandard method can be safely
switched over at the above places in the sources
to use properly standards-compliant Derive method.
@cjdelisle
Copy link
Member

Check the wallet seed code, I believe it's versioned. Correct-bip32 can become seed version number 2.

@cjdelisle cjdelisle merged commit 4188c38 into pkt-cash:develop Nov 18, 2020
@johnsonjh
Copy link
Author

++

@johnsonjh johnsonjh deleted the bip32fix branch December 28, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants